package com.coder.algorithm.leetcode

/**
 * [344. 反转字符串](https://leetcode-cn.com/problems/reverse-string/)
 *
 * @author yuhus
 * @date: 2022/3/28
 */
object l_0344 {
    fun reverseString(s: CharArray): Unit {
        reverseWords(s, 0, s.size - 1)
    }

    private fun reverseWords(charArray: CharArray, l: Int, r: Int) {
        var start = l
        var end = r
        var temp: Char
        while (start < end) {
            temp = charArray[start]
            charArray[start] = charArray[end]
            charArray[end] = temp
            start++
            end--
        }
    }
}